<template>
	<view>
		<view class="maintenanceHome">
			<view class="maintenanceHome-top ff-bg-f5" :style="tabberStyle1" v-if="roleStatus == 2">
				<view class="maintenanceHome-top-header">
					<image class="topHeader"
						src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/company-home-bg.png"
						mode="">
					</image>
					<view
						class="maintenanceHome-top-header-content ff-flex-around ff-align-items-one ff-text-center ff-color-fff">
						<view @click="goResponseRecord">
							<u-count-to :start-val="0" :end-val="orgProjectNumList.respNum" font-size="34"
								color="#fff"></u-count-to>
							<!-- <view class="ff-font-17 ff-margin-bottom-10">{{ orgProjectNumList.respNum }}</view> -->
							<view class="ff-font-14 ff-margin-top-10">响应记录</view>
						</view>
						<view>
							<u-count-to :start-val="0" :end-val="orgProjectNumList.bidNum" font-size="34"
								color="#fff"></u-count-to>
							<view class="ff-font-14 ff-margin-top-10">项目</view>
						</view>
						<view>
							<u-count-to :start-val="0" :end-val="orgProjectNumList.waitingNum" font-size="34"
								color="#fff"></u-count-to>
							<view class="ff-font-14 ff-margin-top-10">待维保</view>
						</view>
						<view>
							<u-count-to :start-val="0" :end-val="orgProjectNumList.maintingNum" font-size="34"
								color="#fff"></u-count-to>
							<view class="ff-font-14 ff-margin-top-10">维保中</view>
						</view>
					</view>
				</view>
				<view
					class="maintenanceHome-top-tipsBox ff-align-items-one ff-color-fff ff-flex-between ff-bg-fff ff-border-radius-15 ff-margin-left-15 ff-margin-right-15">
					<view @click="personnelManagementClick"
						class="maintenanceHome-top-tipsBox-left ff-font-17 ff-align-items ff-border-radius-10">
						<view>
							人员管理
							<u-badge type="error" v-if="orgProjectNumList.waitValidStaffNum > 0"
								:count="orgProjectNumList.waitValidStaffNum"></u-badge>
						</view>
						<image class="ff-margin-left-18"
							src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/company-go.png"
							mode="">
						</image>
						<image class="tipsImg"
							src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/company-personel.png"
							mode=""></image>
					</view>
					<view @click="releaseRequirementsClick"
						class="maintenanceHome-top-tipsBox-right ff-bg-device ff-font-17 ff-align-items ff-border-radius-10">
						<view>设备管理</view>
						<image class="ff-margin-left-18"
							src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/company-go.png"
							mode="">
						</image>
						<image class="tipsImg"
							src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/maintenance-device.png"
							mode=""></image>
					</view>
				</view>
				<view
					class="maintenanceHome-top-notice ff-margin-top-10 ff-margin-left-15 ff-margin-right-15 ff-border-radius-20 ff-bg-f5">
					<f-notice ref="notice" />
				</view>
				<u-sticky offset-top="0" bg-color="#f5f5f5">
					<view
						class="ff-overflow-hidden ff-relative ff-zIndex-999 ff-border-radius-5 ff-padding-top-10 ff-padding-left-15 ff-padding-right-15 ff-bg-f5">
						<u-tabs bg-color="#f5f5f5" :list="adminTypeList" :show-zero="true" :current="typeCurrent"
							active-color="#3178FF" @change="tabberChange"></u-tabs>
					</view>
					<view v-show="searchInp"
						class="ff-bg-f5 ff-padding-left-15 ff-padding-right-15 ff-padding-top-12 ff-padding-bottom-12">
						<u-search v-model="params.keyword" input-align="center" @change="projectNameChange"
							bg-color="#FFFFFF" :height="72" :show-action="false" :clearabled="true"
							placeholder="请输入要搜索的项目名称"></u-search>
					</view>
				</u-sticky>
			</view>
			<view class="maintenanceHome-top ff-bg-f5" :style="tabberStyle1" v-if="roleStatus == 3">
				<view class="maintenanceHome-top-header header-staff">
					<image class="topHeader"
						src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/company-home-bg.png"
						mode="">
					</image>
					<view
						class="maintenanceHome-top-header-content ff-flex-around ff-align-items-one ff-text-center ff-color-fff">
						<view>
							<view class="ff-font-17 ff-margin-bottom-10">{{ orgProjectNumList.maintNum }}</view>
							<view class="ff-font-14">已维保</view>
						</view>
						<view>
							<view class="ff-font-17 ff-margin-bottom-10">{{ orgProjectNumList.waitingNum }}</view>
							<view class="ff-font-14">待维保</view>
						</view>
						<view>
							<view class="ff-font-17 ff-margin-bottom-10">{{ orgProjectNumList.verifyNum }}</view>
							<view class="ff-font-14">待审批</view>
						</view>
					</view>
				</view>
				<f-notice ref="notice" />
				<u-sticky offset-top="0">
					<view class="ff-border-radius-5 ff-relative ff-zIndex-999">
						<u-tabs bg-color="#fff" :list="staffTypeList" :show-zero="true" :current="typeCurrent"
							active-color="#3178FF" @change="staffTabberChange"></u-tabs>
					</view>
					<view v-show="searchInp"
						class="ff-bg-f5 ff-padding-left-15 ff-padding-right-15 ff-padding-top-12 ff-padding-bottom-12">
						<u-search v-model="params.keyword" input-align="center" @change="projectNameChange"
							bg-color="#FFFFFF" :height="80" :show-action="false" :clearabled="true"
							placeholder="请输入要搜索的项目名称"></u-search>
					</view>
				</u-sticky>
			</view>
			<!-- 列表数据 -->
			<view v-if="mechanismList">
				<view v-if="mechanismList.length > 0" class="maintenanceHome-content staff-top"
					:class="{ 'staff-top1': roleStatus == 2, 'staff-top2': roleStatus == 3 }">
					<view class="maintenanceHome-content-box ff-margin-bottom-12 ff-bg-fff ff-border-radius-10"
						v-for="(item, index) of mechanismList" :key="index">
						<view class="ff-border-bottom ff-padding-15 ff-border-radius-10"
							@click.stop="mechanismClick(item)">
							<view class="ff-font-16 ff-color-333 ff-font-weight-600 ff-ellipsis-1 ff-line-height-1-2">
								{{ item.projectName }}
							</view>
							<view v-if="item.rescissionStatus == 1 && item.rescissionPromoterStatus == 2"
								class="rescindTips ff-padding-7 ff-border-radius-5 ff-color-fff ff-font-12 ff-line-height-1-5 ff-margin-top-9 ff-margin-bottom-5">
								请注意，社会单位已对本项目发起解约申请，点击进入项目详情查看与处理。如有异议，请尽快与单位联系。
							</view>
							<view class="ff-align-items-one ff-flex-wrap">
								<view class="ff-margin-right-10">
									<view v-if="item.projectStatus == 0" class="tips1 ff-font-12">项目状态&nbsp;|&nbsp;已发布
									</view>
									<view v-if="item.projectStatus == 1" class="tips1 ff-font-12">项目状态&nbsp;|&nbsp;已响应
									</view>
									<view v-if="item.projectStatus == 2" class="tips1 ff-font-12">项目状态&nbsp;|&nbsp;已确认
									</view>
									<view v-if="item.projectStatus == 3" class="tips1 ff-font-12">项目状态&nbsp;|&nbsp;进行中
									</view>
									<view v-if="item.projectStatus == 4" class="tips1 ff-font-12">项目状态&nbsp;|&nbsp;已结束
									</view>
									<view v-if="item.projectStatus == 5" class="tips1 ff-font-12">项目状态&nbsp;|&nbsp;待批准
									</view>
									<view v-if="item.projectStatus == 6" class="tips6 ff-font-12">项目状态&nbsp;|&nbsp;已解约
									</view>
									<view v-if="item.projectStatus == 9" class="tips6 ff-font-12">项目状态&nbsp;|&nbsp;已作废
									</view>
								</view>
								<view class="ff-margin-right-10" v-if="item.projectStatus == 3">
									<view v-if="item.status == 0" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;待维保</view>
									<view v-if="item.status == 1" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;维保中</view>
									<view v-if="item.status == 2" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;待审核</view>
									<view v-if="item.status == 3" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;待签发</view>
									<view v-if="item.status == 5" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;已完成</view>
									<view v-if="item.status == 6" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;已驳回</view>
									<view v-if="item.status == 7" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;待指派</view>
									<view v-if="item.status == 8" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;待提交</view>
									<view v-if="item.status == 9" class="tips6 ff-font-12">维保状态&nbsp;|&nbsp;已作废</view>
								</view>
								<view class="ff-flex-wrap">
									<view class="tips3 ff-font-12 ff-margin-right-10" v-if="item.doneNumber">
										已完成{{ item.doneNumber }}次执业</view>
									<view
										v-if="(item.rescissionStatus == 0 || item.rescissionStatus == 1) && item.status == 7"
										class="ff-align-items">
										<view v-if="roleStatus == 2 && (typeCurrent == 1 || typeCurrent == 0)">
											<view class="tips3 ff-font-12 ff-margin-right-10"
												v-if="item.doneNumber + item.cancelNumber + 1 > 0">
												正在进行第{{ item.doneNumber + item.cancelNumber + 1 }}次指派</view>
										</view>
									</view>
									<view
										v-if="item.status == 0 || item.status == 1 || item.status == 2 || item.status == 3"
										class="ff-align-items">
										<view class="tips3 ff-font-12 ff-margin-right-10"
											v-if="item.doneNumber + item.cancelNumber + 1 > 0">
											正在进行第{{ item.doneNumber + item.cancelNumber + 1 }}次执业</view>
									</view>
								</view>
								<view v-if="item.rescissionStatus == 1"
									class="tips4 ff-color-fff ff-font-12 ff-margin-right-10">解约确认中</view>
								<view class="tips5 ff-font-12"
									v-if="roleStatus == 2 && item.needWorkHoursFmt &&  (typeCurrent == 1 || typeCurrent == 0)">
									所需工时：{{ item.needWorkHoursFmt }}</view>
							</view>
							<view class="ff-margin--7" v-if="!item.modified"></view>
							<view class="ff-font-13 maintenanceHome-content-box-time" v-if="item.modified">
								更新于：{{ item.modified == null ? '/' : item.modified.substr(0, item.modified.length - 3) }}
							</view>
						</view>
						<view class="maintenanceHome-content-box-butList ff-padding-right-15 ff-justify-end">
							<view class=" ff-padding-top-15 ff-padding-bottom-15"
								v-if="roleStatus == 2 && (typeCurrent == 1||typeCurrent == 0)&& item.status == 7">
								<u-button type="primary" size="mini" @click.stop="assignClick(item, 1)">指派</u-button>
							</view>
							<view class="ff-padding-top-15 ff-padding-bottom-15"
								v-if="roleStatus == 2 && (item.status == 0 || item.status == 1 || item.status == 3)">
								<u-button type="primary" size="mini" @click.stop="assignClick(item, 2)">重新指派</u-button>
							</view>
							<view class="ff-padding-top-15 ff-padding-bottom-15"
								v-if="item.status == 0 || item.status == 1">
								<u-button @click.stop="goMaintenanceClick(item)" type="primary"
									size="mini">去维保</u-button>
							</view>
							<view class="ff-padding-top-15 ff-padding-bottom-15" v-if="item.status == 2">
								<view v-if="userInfo.id == item.leaders[0].userId"><u-button
										@click.stop="reportClick(item)" type="primary" size="mini">审核报告书</u-button>
								</view>
								<view v-else><u-button type="primary" plain size="mini"
										@click.stop="reportClick(item)">查看报告书</u-button></view>
							</view>
							<view class="ff-padding-top-15 ff-padding-bottom-15" v-if="item.status == 3">
								<view v-if="userInfo.id == item.signers[0].userId"><u-button type="primary" size="mini"
										@click.stop="reportClick(item)">签发报告书</u-button></view>
								<view v-else><u-button type="primary" plain size="mini"
										@click.stop="reportClick(item)">查看报告书</u-button></view>
							</view>
							<view class="ff-padding-top-15 ff-padding-bottom-15" v-if="item.status == 6">
								<view v-if="userInfo.id == item.leaders[0].userId"><u-button type="primary" plain
										size="mini" @click.stop="reportClick(item)">查看报告书</u-button></view>
								<view v-else-if="isCheckOperators(userInfo.id, item.operators)">
									<u-button type="primary" size="mini"
										@click.stop="reportClick(item)">编辑报告书</u-button>
								</view>
								<view v-else><u-button type="primary" plain size="mini"
										@click.stop="reportClick(item)">查看报告书</u-button></view>
							</view>
							<view class="ff-padding-top-15 ff-padding-bottom-15" v-if="item.status == 8">
								<view v-if="userInfo.id != item.leaders[0].userId"><u-button type="primary" size="mini"
										@click.stop="reportClick(item)">填写报告书</u-button></view>
								<view v-else><u-button type="primary" plain size="mini"
										@click.stop="reportClick(item)">查看报告书</u-button></view>
							</view>
						</view>
					</view>
					<u-divider v-if="noData" border-color="#909399" height="120" margin-bottom="30" color="#909399"
						bg-color="#f5f5f5">没有更多了</u-divider>
				</view>
				<view v-else>
					<f-noData v-if="roleStatus == 2" :topStyle.sync="topStyleAdmin"></f-noData>
					<f-noData v-else :topStyle.sync="topStyleStaff"></f-noData>
				</view>
			</view>
		</view>
		<!-- 弹窗区 -->
		<u-toast ref="uToast" />
		<f-loading ref="loading" />
		<u-modal v-model="corrigendumModel" @confirm="corrigendumConfirm" title="温馨提示" show-cancel-button="true"
			:content-style="{ 'line-height': '1.5' }" content="请按照建筑物实际消防设施数量准确填写基础数据，后期无法再次修改本次维保数据！" />
		<u-modal v-model="tipsModel" title="温馨提示" :content-style="{ 'line-height': '1.5' }" :content="tipsContent" />
		<!-- 自定义弹窗 -->
		<f-showModel @setVisible="setVisible" :customShowModal.sync="customShowModal" />
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	export default {
		name: 'maintenanceHome',
		data() {
			return {
				// 自定义弹窗内容
				customShowModal: {
					visible: false, // 显隐
					title: '', // 标题,
					content: '', // 内容,
					cancelText: '', // 取消按钮文案,
					confirmText: '', // 确定按钮文案
					messageType: '', // 到期or未到期
					operatorFlag: null, // 单证/双证
				},
				searchInp: true, // 搜索框显/隐藏
				tipsModel: false, // 提示弹窗
				tipsContent: '',
				corrigendumModel: false, // 第一次勘误弹框显/隐
				corrigendumParams: {}, // 第一次勘误点击获取当前列表都的参数
				// 7.待指派 0.待维保 1.维保中 8.待提交 2.待审核 3.待签发 6.已驳回 5.已完成
				// 管理员
				adminTypeList: [{
						name: '我的任务',
						count: 0
					},
					{
						name: '待指派',
						count: 0
					},
					{
						name: '待维保'
					},
					{
						name: '维保中'
					},
					{
						name: '待提交'
					},
					{
						name: '待审核'
					},
					{
						name: '待签发'
					},
					{
						name: '已驳回'
					}
				],
				// 普通员工
				staffTypeList: [{
						name: '我的任务',
						count: 0
					},
					{
						name: '待维保'
					},
					{
						name: '维保中'
					},
					{
						name: '待提交'
					},
					{
						name: '待审核'
					},
					{
						name: '待签发'
					},
					{
						name: '已驳回'
					},
				],
				typeCurrent: 0, // tabs切换index
				choiceActive: true, // tabs选择状态
				topStyleAdmin: '55%', // 暂无数据的css top状态(管理员)
				topStyleStaff: '35%', // 暂无数据的css top状态(员工)
				// 机构项目数量
				orgProjectNumList: {
					bidNum: '',
					maintingNum: '',
					respNum: '',
					waitingNum: '',
				},
				numListUrl: '', // 统计数量的url
				projectListUrl: '', // 任务列表的url
				mechanismList: [], // 机构列表数据 // 机构列表数据请求的参数，维保状态(7.待指派 0.待维保 1.维保中 8.待提交 2.待审核 3.待签发 5.已完成 6.已驳回 9.已作废)
				mechanismAssignedList: [], // 待指派列表数据
				total: 0,
				infoListMechanism: [],
				params: {
					current: 1,
					size: 15,
					status: '',
					keyword: ''
				},
				noData: false, // 没有更多了
			};
		},
		mounted() {
			this.getSpotCheck(); // 判断是否需要抽查
			this.getQueryUserNotReadLog() // 判断是否需要作废提示
			this.getMechanismProjectNumList(); // 获取机构所有项目的数量
			this.getMechanismList(); // 获取机构的列表数据
		},
		computed: {
			// 用户角色状态
			...mapState({
				roleStatus: modules => modules.infoList.roleStatus,
				userInfo: modules => modules.infoList
					.userInfo
			}),
			tabberStyle() {
				return `top:${this.customBar}px;`;
			}
		},
		methods: {
			// onShow监听刷新
			showLoading() {
				this.params.current = 1;
				this.getSpotCheck(); // 判断是否需要抽查
				this.getQueryUserNotReadLog() // 判断是否需要作废提示
				this.getMechanismList(); // 获取的机构项目数据列表
				this.getMechanismProjectNumList(); // 获取机构所有项目的数量
				this.$refs.notice.getNotice() // 获取公告列表
			},
			// 上拉加载
			pullLoading() {
				// console.log('上拉加载', this.noData)
				if (!this.noData) {
					this.params.current++;
					this.getMechanismList(); // 获取的数据列表
				}
			},
			// 下拉刷新
			downLoading() {
				let that = this;
				that.params.current = 1;
				that.getMechanismList(); // 获取的数据列表
				that.getMechanismProjectNumList(); // 获取机构所有项目的数量
				that.$refs.notice.getNotice() // 获取公告列表
				setTimeout(() => {
					that.$refs.uToast.show({
						title: '刷新成功',
						type: 'success'
					});
					uni.stopPullDownRefresh(); // 停止刷新
				}, 100);
			},
			// tabber切换---管理员
			tabberChange(e) {
				// console.log(e)
				this.typeCurrent = e;
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 0
				});
				// 1.维保中  7.待指派 0.待维保 8.待提交 2.待审核 3.待签发  6.已驳回  5.已完成
				// 我的任务
				if (e == 0) {
					this.params.current = 1;
					this.params.status = '';
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
				if (e == 1) {
					this.params.current = 1;
					this.getMechanismList(); // 获取的待指派数据列表
					return;
				}
				if (e == 2) {
					this.params.current = 1;
					this.params.status = 0;
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
				if (e == 3) {
					this.params.current = 1;
					this.params.status = 1;
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
				if (e == 4) {
					this.params.current = 1;
					this.params.status = 8;
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
				if (e == 5) {
					this.params.current = 1;
					this.params.status = 2;
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
				if (e == 6) {
					this.params.current = 1;
					this.params.status = 3;
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
				if (e == 7) {
					this.params.current = 1;
					this.params.status = 6;
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
				if (e == 8) {
					this.params.current = 1;
					this.params.status = 5;
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
			},
			// tabber切换---员工
			staffTabberChange(e) {
				this.typeCurrent = e;
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 0
				});
				// 1.维保中 0.待维保 8.待提交 2.待审核 3.待签发 6.已驳回  5.已完成
				// 我的任务
				if (e == 0) {
					this.params.current = 1;
					this.params.status = '';
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
				if (e == 1) {
					this.params.current = 1;
					this.params.status = 0;
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
				if (e == 2) {
					this.params.current = 1;
					this.params.status = 1;
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
				if (e == 3) {
					this.params.current = 1;
					this.params.status = 8;
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
				if (e == 4) {
					this.params.current = 1;
					this.params.status = 2;
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
				if (e == 5) {
					this.params.current = 1;
					this.params.status = 3;
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
				if (e == 6) {
					this.params.current = 1;
					this.params.status = 6;
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
				if (e == 7) {
					this.params.current = 1;
					this.params.status = 5;
					this.getMechanismList(); // 获取的机构项目数据列表
					return;
				}
			},
			// 获取机构维保统计
			async getMechanismProjectNumList() {
				this.$refs.loading.openLoading('加载中···'); // 打开loading动画
				if (this.roleStatus == 2) {
					this.numListUrl = '/serviceOrg/maintenance/manager/statV2';
				} else if (this.roleStatus == 3) {
					this.numListUrl = '/serviceOrg/maintenance/user/statV3';
				}
				const data = await this.$http.get({
					url: this.numListUrl
				});
				// console.log('获取机构维保统计------', data);
				if (data.code == 200) {
					this.orgProjectNumList = data.data;
				}
				this.$refs.loading.closeLoading(); // 关闭loading动画
			},
			// 搜索项目
			projectNameChange() {
				// console.log('当前搜索的值----', this.params)
				this.searchInp = false
				this.params.current = 1;
				this.getMechanismList(); // 获取机构项目的数据列表
			},
			// 获取机构的列表数据(管理员or员工)
			async getMechanismList() {
				this.searchInp = false
				this.$refs.loading.openLoading('加载中···'); // 打开loading动画
				if (this.roleStatus == 2 && this.typeCurrent == 1) {
					this.projectListUrl = '/serviceOrg/project/page/waitingAssigned';
				} else {
					this.projectListUrl = '/serviceOrg/staff/mainTaskPageV3';
				}
				const data = await this.$http.post({
					url: this.projectListUrl,
					data: this.params
				});
				// console.log('获取的机构列表数据------', data);
				if (data.code == 200) {
					this.searchInp = true
					this.$refs.loading.closeLoading(); // 关闭loading动画
					const infoList = data.data.records;
					if (infoList.length == 0 && this.params.current == 1) {
						// console.log('首次加载没数据');
						this.noData = false;
						this.mechanismList = [];
					} else if (infoList.length < 3 && this.params.current == 1) {
						// console.log('首次加载有数据，但少于4条');
						this.noData = true;
						this.mechanismList = infoList;
					} else if (infoList.length !== 0 && this.params.current == 1) {
						// console.log('首次加载有数据');
						this.noData = false;
						this.mechanismList = infoList;
					} else if (infoList.length !== 0 && this.params.current > 1) {
						// console.log('上拉加载更多数据');
						this.noData = false;
						this.mechanismList = this.mechanismList.concat(infoList);
					} else if (infoList.length == 0 && this.params.current > 1) {
						// console.log('上拉加载没有更多数据了');
						this.noData = true;
					}
					// 管理员系列----
					// 我的任务---待指派
					if (this.typeCurrent == 0 && this.roleStatus == 2 && this.params.current == 1) {
						this.mechanismAssignedList = []
						this.infoListMechanism = [] // 存一个新的数据
						this.infoListMechanism = this.mechanismList
						this.total = 0
						this.total = data.data.total
						const numListUrl = '/serviceOrg/project/page/waitingAssigned';
						this.getMechanismAssignedList(numListUrl); // 获取的机构项目数据列表
						return
					}
					// 待指派
					if (this.typeCurrent == 1 && this.roleStatus == 2) {
						this.staffTypeList[1].count = data.data.total
						return
					}
					// 员工系列----
					// 我的任务
					if (this.typeCurrent == 0) {
						this.staffTypeList[0].count = data.data.total
						return
					}
				} else {
					this.$refs.loading.closeLoading(); // 关闭loading动画
					this.searchInp = true
				}
			},
			// 获取我的任务--待指派的数据
			async getMechanismAssignedList(numListUrl) {
				this.searchInp = false
				this.$refs.loading.openLoading('加载中···'); // 打开loading动画
				const data = await this.$http.post({
					url: numListUrl,
					data: this.params
					// {
					// 	current: this.params.current,
					// 	size: 20
					// }
				});
				// console.log('获取的待指派列表数据------', data);
				if (data.code == 200) {
					this.searchInp = true
					this.$refs.loading.closeLoading(); // 关闭loading动画
					const infoList = data.data.records;
					this.mechanismAssignedList = infoList;
					this.adminTypeList[0].count = this.total * 1 + data.data.total * 1
					this.adminTypeList[1].count = data.data.total * 1
					this.mechanismList = this.mechanismAssignedList.concat(this.infoListMechanism)
				} else {
					this.$refs.loading.closeLoading(); // 关闭loading动画
					this.searchInp = true
				}
			},
			// 点击进入响应记录列表页面
			goResponseRecord() {
				this.$pageJump.navigateTo('/pages/maintenance/mechanism/home/components/response/responseRecord');
			},
			// 点击项目列表进入详情
			mechanismClick(item) {
				// 项目状态: 0.已发布 1.已响应 3.进行中 4.已结束 5.待审核
				this.$pageJump.navigateTo(
					'/pages/maintenance/mechanism/home/components/details/projectMaintenanceRecord?id=' + item
					.projectId);
			},
			// 点击进入人员管理页面
			personnelManagementClick() {
				this.$pageJump.navigateTo(
					'/pages/maintenance/mechanism/home/components/personnelManagement/personnelManagement');
			},
			// 点击进入设备管理页面
			releaseRequirementsClick() {
				this.$pageJump.navigateTo(
					'/pages/maintenance/mechanism/home/components/deviceManagement/deviceManagement');
			},
			// 循环比较执业人员是否有权限编辑报告书
			isCheckOperators(curId, recordId) {
				for (let i = 0; i < recordId.length; i++) {
					if (curId == recordId[i].userId) {
						return true;
					}
				}
				return false;
			},
			// 指派 or 重新指派
			assignClick(item, type) {
				// console.log(item, type, 'item, type')
				// projectId----项目ID, maintenanceId----维保记录ID
				let {
					projectName,
					...otherItem
				} = item
				let items = Object.assign(otherItem, {
					type: type
				});
				this.$pageJump.navigateTo('/pages/maintenance/mechanism/home/components/assign/Assign?params=' + JSON
					.stringify(items));
			},
			// 去维保
			async goMaintenanceClick(item) {
				// console.log('item--------', item);
				// 是否已勘误  hasCorrected：1.未勘误 2.已完成第一次勘误 3.已完成第二次勘误
				// 解约状态rescissionStatus：0.未解约 1.解约确认中 2.解约完成
				// if (item.rescissionStatus == 1) {
				// 	this.tipsModel = true
				// 	this.tipsContent = '该任务处于解约确认中不能进行维保！'
				// 	return;
				// }

				// 检查证书是否到期
				const data = await this.$http.post({
					url: '/maintenance/checkForCertificate?maintenanceId=' + item.maintenanceId,

				})
				// console.log('检查证书是否到期', data)
				if (data.code == 200) {
					if (data.data.certificateInValid && data.data.leader) {
						this.customShowModal.visible = true // 显隐
						this.customShowModal.title = '证书已到期' // 标题
						this.customShowModal.content = data.data.msg
					} else {
						if (item.rescissionStatus == 2) {
							this.tipsModel = true;
							this.tipsContent = '该任务已解约，不能进行维保！';
							return;
						}
						// 未勘误----
						if (item.hasCorrected == 1 && this.userInfo.id == item.leaders[0].userId) {
							this.threeMergeIntoOneItemCheck(item) // 检测是否三合一勘误（项目负责人检测）
							return;
						}
						// 勘误完项目负责人需检测是否需要三合一
						if (this.userInfo.id == item.leaders[0].userId) {
							this.threeMergeIntoOneItemCheck1(item) // 检测是否三合一勘误（项目负责人检测）
							return;
						} else {
							// 跳转到去维保的页面
							this.$pageJump.navigateTo(
								'/pages/maintenance/mechanism/home/components/mechanismWork/mechanismWorking?maintenanceId=' +
								item
								.maintenanceId);
						}
					}
				} else {
					uni.showModal({
						title: '温馨提示',
						content: data.msg,
						confirmColor: '#3178FF',
						showCancel: false,
						success: function(res) {
							if (res.confirm) {
								// console.log('用户点击确定')
							}
						},
					})
				}
			},
			// 关闭弹窗
			setVisible() {
				this.customShowModal.visible = false // 显隐
			},
			// 检测是否三合一勘误（项目负责人检测）
			async threeMergeIntoOneItemCheck(item) {
				const data = await this.$http.get({
					url: `/maintenance/threeMergeIntoOneItemCheck/${item.maintenanceId}`
				})
				// console.log('检测是否三合一勘误（项目负责人检测）', data)
				if (data.code == 200) {
					if (data.data.needCorrect) {
						// 跳转到三合一勘误的页面
						this.$pageJump.navigateTo(
							'/pages/maintenance/mechanism/home/components/corrigendum/threeInOne?maintenanceId=' +
							item.maintenanceId +
							'&oldItemNumber=' + data.data.oldItemNumber + '&projectId=' + item.projectId);
					} else {
						// 打开勘误提示
						this.corrigendumModel = true;
						this.corrigendumParams = item;
					}
				} else {
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error'
					});
				}
			},
			// 检测是否三合一勘误(是否需要三合一检测不需要直接跳转维保执业页面)（项目负责人检测）
			async threeMergeIntoOneItemCheck1(item) {
				const data = await this.$http.get({
					url: `/maintenance/threeMergeIntoOneItemCheck/${item.maintenanceId}`
				})
				// console.log('检测是否三合一勘误（项目负责人检测）', data)
				if (data.code == 200) {
					if (data.data.needCorrect) {
						// 跳转到三合一勘误的页面
						this.$pageJump.navigateTo(
							'/pages/maintenance/mechanism/home/components/corrigendum/threeInOne?maintenanceId=' +
							item.maintenanceId +
							'&oldItemNumber=' + data.data.oldItemNumber + '&projectId=' + item.projectId +
							'&type=' + 1);
					} else {
						// 跳转到去维保的页面
						this.$pageJump.navigateTo(
							'/pages/maintenance/mechanism/home/components/mechanismWork/mechanismWorking?maintenanceId=' +
							item
							.maintenanceId);
					}
				} else {
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error'
					});
				}
			},
			// 未勘误弹窗-----确定
			corrigendumConfirm() {
				// type:1 ---未勘误 维保前   type:2，维保后
				let paramsInfo = {
					projectId: this.corrigendumParams.projectId,
					maintenanceId: this.corrigendumParams.maintenanceId,
					type: 1
				};
				this.$pageJump.navigateTo(
					'/pages/maintenance/mechanism/home/components/corrigendum/Corrigendum?paramsInfo=' +
					JSON.stringify(paramsInfo));
			},
			// 填写报告书, 审核报告书, 签发报告书, 编辑报告书, 查看报告书
			reportClick(item) {
				this.$pageJump.navigateTo('/pages/maintenance/mechanism/home/components/details/Report?id=' + item
					.maintenanceId);
			},
			// 判断是否需要抽查
			async getSpotCheck() {
				const data = await this.$http.post({
					url: '/serviceOrg/checkTask/userPage',
					data: {
						current: 1,
						size: 1,
						checkStatus: 1
					}
				});
				// console.log('有待抽查任务需要处理,请立即处理-----', data.data.records);
				if (data.code == 200 && data.data.records.length > 0) {
					let receiveTime = data.data.records[0].receiveTime // 系统开始抽查时间
					if (this.diffTime(receiveTime) < 15) {
						this.$emit('getCheck')
					}
				}
			},
			// 计算时间差
			diffTime(start) {
				let staytimeGap = new Date().getTime() - new Date(start).getTime();
				let stayMin = Math.floor(staytimeGap / (60 * 1000)); // 分钟
				return stayMin
			},
			// 抽查--确认操作
			checkConfirm() {
				this.$pageJump.navigateTo('/pages/maintenance/public/personal/spotTask/spotTask');
			},
			// 判断是否有未读作废提醒
			async getQueryUserNotReadLog() {
				const data = await this.$http.post({
					url: '/serviceOrg/queryUserNotReadLog'
				});
				// console.log('判断是否有未读作废提醒-----', data);
				if (data.code == 200 && data.data.cancelDepartmentName) {
					this.$emit('getTips', data.data)
				}
			},
		}
	};
</script>

<style lang="scss" scoped>
	@import './components/maintenanceHome.scss';

	/deep/.u-badge--bg--error {
		right: 0% !important;
	}

	.tips6 {
		background-color: #a8a7b5;
		color: #fff;
		padding: 12rpx 15rpx;
		border-radius: 8rpx;
		margin-top: 8.5rpx;
		margin-bottom: 8.5rpx;
	}
</style>
<style>
	/* 1:隐藏滚动条，但是可以支持滚动的方法 */
	::-webkit-scrollbar {
		display: none;
	}
</style>